My Bash Commands

Resources:

1. Remove spaces from file and folder names and then remove numbers from files and folder names....

Description: need to : sudo apt install rename

Notes: Issue when renaming file without numbers collides with existing file name...
code:
1
find . -name "* *" -type d | rename 's/ /_/g'
2
find . -name "* *" -type f | rename 's/ /_/g'
Copied!
1
find $dir -type f | sed 's|\(.*/\)[^A-Z]*\([A-Z].*\)|mv \"&\" \"\1\2\"|' | sh
2
3
find $dir -type d | sed 's|\(.*/\)[^A-Z]*\([A-Z].*\)|mv \"&\" \"\1\2\"|' | sh
4
5
for i in *.html; do mv "$i" "${i%-*}.html"; done
6
7
for i in *.*; do mv "$i" "${i%-*}.${i##*.}"; done
Copied!

Description: combine the contents of every file in the contaning directory.

Notes: this includes the contents of the file it's self...
code:
1
//APPEND-DIR.js
2
const fs = require('fs');
3
let cat = require('child_process')
4
.execSync('cat *')
5
.toString('UTF-8');
6
fs.writeFile('output.md', cat, err => {
7
if (err) throw err;
8
});
Copied!

2. Download Website Using Wget:

Description:

Notes: ==> sudo apt install wget
code:
1
wget --limit-rate=200k --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla https://bootcamp42.gitbook.io/python/
Copied!

3. Clean Out Messy Git Repo:

Notes: To clear up clutter in repositories that only get used on your local machine.
code:
1
find . -empty -type d -print -delete
2
3
4
find . \( -name ".git" -o -name ".gitignore" -o -name ".gitmodules" -o -name ".gitattributes" \) -exec rm -rf -- {} +
5
6
7
find . \( -name "*SECURITY.txt" -o -name "*RELEASE.txt" -o -name "*CHANGELOG.txt" -o -name "*LICENSE.txt" -o -name "*CONTRIBUTING.txt" -name "*HISTORY.md" -o -name "*LICENSE" -o -name "*SECURITY.md" -o -name "*RELEASE.md" -o -name "*CHANGELOG.md" -o -name "*LICENSE.md" -o -name "*CODE_OF_CONDUCT.md" -o -name "*CONTRIBUTING.md" \) -exec rm -rf -- {} +
Copied!

4. clone all of a user's git repositories

Description: clone all of a user or organization's git repositories.

Notes:
code:

Generalized:

1
2
CNTX={users|orgs}; NAME={username|orgname}; PAGE=1
3
curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" |
4
grep -e 'git_url*' |
5
cut -d \" -f 4 |
6
xargs -L1 git clone
Copied!

Clone all Git User

1
CNTX={users}; NAME={bgoonz}; PAGE=1
2
curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=200"?branch=master |
3
grep -e 'git_url*' |
4
cut -d \" -f 4 |
5
xargs -L1 git clone
Copied!

Clone all Git Organization:

1
CNTX={organizations}; NAME={TheAlgorithms}; PAGE=1
2
curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=200"?branch=master |
3
grep -e 'git_url*' |
4
cut -d \" -f 4 |
5
xargs -L1 git clone
Copied!

5. Git Workflow

Description:

code:
1
git pull
2
git init
3
git add .
4
git commit -m"update"
5
git push -u origin master
Copied!
1
git init
2
git add .
3
git commit -m"update"
4
git push -u origin main
Copied!
1
git init
2
git add .
3
git commit -m"update"
4
git push -u origin bryan-guner
Copied!
1
git init
2
git add .
3
git commit -m"update"
4
git push -u origin gh-pages
Copied!
1
git init
2
git add .
3
git commit -m"update"
4
git push -u origin preview
Copied!

6. Recursive Unzip In Place

Description: recursively unzips folders and then deletes the zip file by the same name.

Notes:
code:
1
find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;
2
3
4
5
find . -name "*.zip" -type f -print -delete
Copied!

7. git pull keeping local changes:

Description:

Notes:
code:
1
git stash
2
git pull
3
git stash pop
Copied!

8. Prettier Code Formatter:

Description:

Notes:
code:
1
sudo npm i prettier -g
2
3
prettier --write .
Copied!

9. Pandoc

Description:

Notes:
code:
1
find ./ -iname "*.md" -type f -exec sh -c 'pandoc --standalone "${0}" -o "${0%.md}.html"' {} \;
2
3
4
5
find ./ -iname "*.html" -type f -exec sh -c 'pandoc --wrap=none --from html --to markdown_strict "${0}" -o "${0%.html}.md"' {} \;
6
7
8
9
find ./ -iname "*.docx" -type f -exec sh -c 'pandoc "${0}" -o "${0%.docx}.md"' {} \;
Copied!

10. Gitpod Installs

Description:

Notes:
code:
1
sudo apt install tree
2
sudo apt install pandoc -y
3
sudo apt install rename -y
4
sudo apt install black -y
5
sudo apt install wget -y
6
npm i lebab -g
7
npm i prettier -g
8
npm i npm-recursive-install -g
Copied!
1
black .
2
3
prettier --write .
4
npm-recursive-install
Copied!

11. Repo Utils Package:

Description: my standard repo utis package

Notes:
code:
1
npm i @bgoonz11/repoutils
Copied!

12. Unix Tree Package Usage:

Description:

Notes:
code:
1
tree -d -I 'node_modules'
2
3
tree -I 'node_modules'
4
5
tree -f -I 'node_modules' >TREE.md
6
7
tree -f -L 2 >README.md
8
9
tree -f -I 'node_modules' >listing-path.md
10
11
12
tree -f -I 'node_modules' -d >TREE.md
13
14
tree -f >README.md
Copied!

13. Find & Replace string in file & folder names recursively..

Description:

Notes:
code:
1
find . -type f -exec rename 's/string1/string2/g' {} +
2
3
4
find . -type d -exec rename 's/-master//g' {} +
5
6
7
find . -type f -exec rename 's/\.download//g' {} +
8
9
10
11
12
find . -type d -exec rename 's/-main//g' {} +
13
14
15
16
rename 's/\.js\.download$/.js/' *.js\.download
17
18
19
rename 's/\.html\.markdown$/.md/' *.html\.markdown
20
21
22
find . -type d -exec rename 's/es6//g' {} +
Copied!

14. Remove double extensions :

Description:

Notes:
code:
1
#!/bin/bash
2
3
for file in *.md.md
4
do
5
mv "${file}" "${file%.md}"
6
done
7
8
#!/bin/bash
9
10
for file in *.html.html
11
do
12
mv "${file}" "${file%.html}"
13
done
Copied!
1
#!/bin/bash
2
3
for file in *.html.png
4
do
5
mv "${file}" "${file%.png}"
6
done
7
8
for file in *.jpg.jpg
9
do
10
mv "${file}" "${file%.png}"
11
done
Copied!

15. Truncate folder names down to 12 characters:

Description:

Notes:
code:
1
for d in ./*; do mv $d ${d:0:12}; done
Copied!

16.Appendir.js

Description: combine the contents of every file in the contaning directory.

Notes: this includes the contents of the file it's self...
code:
1
//APPEND-DIR.js
2
const fs = require('fs');
3
let cat = require('child_process')
4
.execSync('cat *')
5
.toString('UTF-8');
6
fs.writeFile('output.md', cat, err => {
7
if (err) throw err;
8
});
Copied!

17. Replace space in filename with underscore

Description: followed by replace '#' with '_' in directory name

Notes: Can be re-purposed to find and replace any set of strings in file or folder names.
code:
1
find . -name "* *" -type f | rename 's/_//g'
2
3
find . -name "* *" -type d | rename 's/#/_/g'
Copied!

18. Filter & delete files by name and extension

Description:

Notes:
code:
1
find . -name '.bin' -type d -prune -exec rm -rf '{}' +
2
3
find . -name '*.html' -type d -prune -exec rm -rf '{}' +
4
5
find . -name 'nav-index' -type d -prune -exec rm -rf '{}' +
6
7
find . -name 'node-gyp' -type d -prune -exec rm -rf '{}' +
8
9
find . -name 'deleteme.txt' -type f -prune -exec rm -rf '{}' +
10
11
find . -name 'right.html' -type f -prune -exec rm -rf '{}' +
12
13
find . -name 'left.html' -type f -prune -exec rm -rf '{}' +
Copied!

19. Remove lines containing string:

Description:

Notes: Remove lines not containing '.js'
1
sudo sed -i '/\.js/!d' ./*scrap2.md
Copied!
code:
1
sudo sed -i '/githubusercontent/d' ./*sandbox.md
2
3
4
sudo sed -i '/githubusercontent/d' ./*scrap2.md
5
6
7
8
sudo sed -i '/github\.com/d' ./*out.md
9
10
11
sudo sed -i '/author/d' ./*
Copied!

20. Remove duplicate lines from a text file

Description:

Notes: //...syntax of uniq...// $uniq [OPTION] [INPUT[OUTPUT]] The syntax of this is quite easy to understand. Here, INPUT refers to the input file in which repeated lines need to be filtered out and if INPUT isn’t specified then uniq reads from the standard input. OUTPUT refers to the output file in which you can store the filtered output generated by uniq command and as in case of INPUT if OUTPUT isn’t specified then uniq writes to the standard output.
Now, let’s understand the use of this with the help of an example. Suppose you have a text file named kt.txt which contains repeated lines that needs to be omitted. This can simply be done with uniq.
code:
1
sudo apt install uniq
2
uniq -u input.txt output.txt
Copied!

21. Remove lines containing string:

Description:

Notes:
code:
1
sudo sed -i '/githubusercontent/d' ./*sandbox.md
2
3
4
sudo sed -i '/githubusercontent/d' ./*scrap2.md
5
6
7
sudo sed -i '/github\.com/d' ./*out.md
8
9
---
10
title: add_days
11
tags: date,intermediate
12
firstSeen: 2020-10-28T16:19:04+02:00
13
lastUpdated: 2020-10-28T16:19:04+02:00
14
---
15
16
sudo sed -i '/title:/d' ./*output.md
17
sudo sed -i '/firstSeen/d' ./*output.md
18
sudo sed -i '/lastUpdated/d' ./*output.md
19
sudo sed -i '/tags:/d' ./*output.md
20
21
sudo sed -i '/badstring/d' ./*
22
23
24
sudo sed -i '/stargazers/d' ./repo.txt
25
sudo sed -i '/node_modules/d' ./index.html
26
sudo sed -i '/right\.html/d' ./index.html
27
sudo sed -i '/right\.html/d' ./right.html
Copied!

22. Zip directory excluding .git and node_modules all the way down (Linux)

Description:

Notes:
code:
1
#!/bin/bash
2
TSTAMP=`date '+%Y%m%d-%H%M%S'`
3
zip -r $1.$TSTAMP.zip $1 -x "**.git/*" -x "**node_modules/*" `shift; echo [email protected];`
4
5
printf "\nCreated: $1.$TSTAMP.zip\n"
6
7
# usage:
8
# - zipdir thedir
9
# - zip thedir -x "**anotherexcludedsubdir/*" (important the double quotes to prevent glob expansion)
10
11
# if in windows/git-bash, add 'zip' command this way:
12
# https://stackoverflow.com/a/55749636/1482990
Copied!

23. Delete files containing a certain string:

Description:

Notes:
code:
1
find . | xargs grep -l www.redhat.com | awk '{print "rm "$1}' > doit.sh
2
vi doit.sh // check for murphy and his law
3
source doit.sh
Copied!

24.

Description:

Notes:
code:
1
#!/bin/sh
2
3
# find ./ | grep -i "\.*quot; >files
4
find ./ | sed -E -e 's/([^ ]+[ ]+){8}//' | grep -i "\.*quot;>files
5
listing="files"
6
7
out=""
8
9
html="sitemap.html"
10
out="basename $out.html"
11
html="sitemap.html"
12
cmd() {
13
14
echo ' <!DOCTYPE html>'
15
echo '<html>'
16
echo '<head>'
17
18
echo ' <meta http-equiv="Content-Type" content="text/html">'
19
20
echo ' <meta name="Author" content="Bryan Guner">'
21
echo '<link rel="stylesheet" href="./assets/prism.css">'
22
echo ' <link rel="stylesheet" href="./assets/style.css">'
23
echo ' <script async defer src="./assets/prism.js"></script>'
24
25
echo " <title> directory </title>"
26
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/bgoonz/GIT-CDN-FILES/mdn-article.css">'
27
echo '<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/bgoonz/GIT-CDN-FILES/markdown-to-html-style.css">'
28
echo ""
29
echo '<style>'
30
31
32
echo ' a {'
33
echo ' color: black;'
34
echo ' }'
35
echo ''
36
echo ' li {'
37
echo ' border: 1px solid black !important;'
38
echo ' font-size: 20px;'
39
echo ' letter-spacing: 0px;'
40
echo ' font-weight: 700;'
41
echo ' line-height: 16px;'
42
echo ' text-decoration: none !important;'
43
echo ' text-transform: uppercase;'
44
echo ' background: #194ccdaf !important;'
45
echo ' color: black !important;'
46
echo ' border: none;'
47
echo ' cursor: pointer;'
48
echo ' justify-content: center;'
49
echo ' padding: 30px 60px;'
50
echo ' height: 48px;'
51
echo ' text-align: center;'
52
echo ' white-space: normal;'
53
echo ' border-radius: 10px;'
54
echo ' min-width: 45em;'
55
echo ' padding: 1.2em 1em 0;'
56
echo ' box-shadow: 0 0 5px;'
57
echo ' margin: 1em;'
58
echo ' display: grid;'
59
echo ' -webkit-border-radius: 10px;'
60
echo ' -moz-border-radius: 10px;'
61
echo ' -ms-border-radius: 10px;'
62
echo ' -o-border-radius: 10px;'
63
echo ' }'
64
echo ' </style>'
65
echo '</head>'
66
67
echo '<body>'
68
69
echo ""
70
71
# continue with the HTML stuff
72
73
echo ""
74
75
echo ""
76
77
echo "<ul>"
78
79
awk '{print "<li><a href=\""$1"\">",$1,"&nbsp;</a></li>"}' $listing
80
81
# awk '{print "<li>"};
82
83
# {print " <a href=\""$1"\">",$1,"</a></li>&nbsp;"}' \ $listing
84
85
echo ""
86
87
echo "</ul>"
88
89
echo "</body>"
90
91
echo "</html>"
92
93
}
94
95
cmd $listing --sort=extension >>$html
Copied!

25. Index of Iframes

Description: Creates an index.html file that contains all the files in the working directory or any of it's sub folders as iframes instead of anchor tags.

Notes: Useful Follow up Code:
1
Copied!
code:
1
#!/bin/sh
2
3
# find ./ | grep -i "\.*quot; >files
4
find ./ | sed -E -e 's/([^ ]+[ ]+){8}//' | grep -i "\.*quot;>files
5
listing="files"
6
7
out=""
8
9
html="index.html"
10
out="basename $out.html"
11
html="index.html"
12
cmd() {
13
14
echo ' <!DOCTYPE html>'
15
echo '<html>'
16
echo '<head>'
17
18
echo ' <meta http-equiv="Content-Type" content="text/html">'
19
20
echo ' <meta name="Author" content="Bryan Guner">'
21
echo '<link rel="stylesheet" href="./assets/prism.css">'
22
echo ' <link rel="stylesheet" href="./assets/style.css">'
23
echo ' <script async defer src="./assets/prism.js"></script>'
24
25
echo " <title> directory </title>"
26
27
echo ""
28
echo '<style>'
29
30
31
echo ' a {'
32
echo ' color: black;'
33
echo ' }'
34
echo ''
35
echo ' li {'
36
echo ' border: 1px solid black !important;'
37
echo ' font-size: 20px;'
38
echo ' letter-spacing: 0px;'
39
echo ' font-weight: 700;'
40
echo ' line-height: 16px;'
41
echo ' text-decoration: none !important;'
42
echo ' text-transform: uppercase;'
43
echo ' background: #194ccdaf !important;'
44
echo ' color: black !important;'
45
echo ' border: none;'
46
echo ' cursor: pointer;'
47
echo ' justify-content: center;'
48
echo ' padding: 30px 60px;'
49
echo ' height: 48px;'
50
echo ' text-align: center;'
51
echo ' white-space: normal;'
52
echo ' border-radius: 10px;'
53
echo ' min-width: 45em;'
54
echo ' padding: 1.2em 1em 0;'
55
echo ' box-shadow: 0 0 5px;'
56
echo ' margin: 1em;'
57
echo ' display: grid;'
58
echo ' -webkit-border-radius: 10px;'
59
echo ' -moz-border-radius: 10px;'
60
echo ' -ms-border-radius: 10px;'
61
echo ' -o-border-radius: 10px;'
62
echo ' }'
63
echo ' </style>'
64
echo '</head>'
65
66
echo '<body>'
67
68
echo ""
69
70
# continue with the HTML stuff
71
72
echo ""
73
74
echo ""
75
76
echo "<ul>"
77
78
awk '{print "<iframe src=\""$1"\">","</iframe>"}' $listing
79
80
# awk '{print "<li>"};
81
82
# {print " <a href=\""$1"\">",$1,"</a></li>&nbsp;"}' \ $listing
83
84
echo ""
85
86
echo "</ul>"
87
88
echo "</body>"
89
90
echo "</html>"
91
92
}
93
94
cmd $listing --sort=extension >>$html
Copied!

26. Filter Corrupted Git Repo For Troublesome File:

Description:

Notes:
code:
1
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch assets/_index.html' HEAD
Copied!

27. OVERWRITE LOCAL CHANGES:

Description:

Important: If you have any local changes, they will be lost. With or without --hard option, any local commits that haven't been pushed will be lost.[*] If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected.
Notes: First, run a fetch to update all origin/ refs to latest:
code:
1
git fetch --all
2
# Backup your current branch:
3
4
git branch backup-master
5
# Then, you have two options:
6
7
git reset --hard origin/master
8
# OR If you are on some other branch:
9
10
git reset --hard origin/<branch_name>
11
# Explanation:
12
# git fetch downloads the latest from remote without trying to merge or rebase anything.
13
14
# Then the git reset resets the master branch to what you just fetched. The --hard option changes all the files in your working tree to match the files in origin/master
15
git fetch --all
16
git reset --hard origin/master
Copied!

28. Remove Submodules:

Description: To remove a submodule you need to:

Notes:
Delete the relevant section from the .gitmodules file. Stage the .gitmodules changes git add .gitmodules Delete the relevant section from .git/config. Run git rm --cached path_to_submodule (no trailing slash). Run rm -rf .git/modules/path_to_submodule (no trailing slash). Commit git commit -m "Removed submodule " Delete the now untracked submodule files rm -rf path_to_submodule
code:
1
git submodule deinit
Copied!

29. GET GISTS

Description:

Notes:
code:
1
sudo apt install wget
2
3
4
5
wget -q -O - https://api.github.com/users/bgoonz/gists | grep raw_url | awk -F\" '{print $4}' | xargs -n3 wget
6
7
8
wget -q -O - https://api.github.com/users/amitness/gists | grep raw_url | awk -F\" '{print $4}' | xargs -n3 wget
9
10
11
wget -q -O - https://api.github.com/users/drodsou/gists | grep raw_url | awk -F\" '{print $4}' | xargs -n1 wget
12
13
wget -q -O - https://api.github.com/users/thomasmb/gists | grep raw_url | awk -F\" '{print $4}' | xargs -n1 wget
Copied!

30. Remove Remote OriginL

Description:

Notes:
code:
1
git remote remove origin
Copied!

31. just clone .git folder:

Description:

Notes:
code:
1
git clone --bare --branch=master --single-branch https://github.com/bgoonz/My-Web-Dev-Archive.git
Copied!

32. Undo recent pull request:

Description:

Notes:
code:
1
git reset --hard [email protected]{"10 minutes ago"}
Copied!

33. Lebab

Description: ES5 --> ES6

Notes:
code:
1
# Safe:
2
3
lebab --replace ./ --transform arrow
4
lebab --replace ./ --transform arrow-return
5
lebab --replace ./ --transform for-of
6
lebab --replace ./ --transform for-each
7
lebab --replace ./ --transform arg-rest
8
lebab --replace ./ --transform arg-spread
9
lebab --replace ./ --transform obj-method
10
lebab --replace ./ --transform obj-shorthand
11
lebab --replace ./ --transform multi-var
12
13
14
# ALL:
15
16
17
lebab --replace ./ --transform obj-method
18
lebab --replace ./ --transform class
19
lebab --replace ./ --transform arrow
20
lebab --replace ./ --transform let
21
lebab --replace ./ --transform arg-spread
22
lebab --replace ./ --transform arg-rest
23
lebab --replace ./ --transform for-each
24
lebab --replace ./ --transform for-of
25
lebab --replace ./ --transform commonjs
26
lebab --replace ./ --transform exponent
27
lebab --replace ./ --transform multi-var
28
lebab --replace ./ --transform template
29
lebab --replace ./ --transform default-param
30
lebab --replace ./ --transform destruct-param
31
lebab --replace ./ --transform includes
32
lebab --replace ./ --transform obj-method
33
lebab --replace ./ --transform class
34
lebab --replace ./ --transform arrow
35
lebab --replace ./ --transform arg-spread
36
lebab --replace ./ --transform arg-rest
37
lebab --replace ./ --transform for-each
38
lebab --replace ./ --transform for-of
39
lebab --replace ./ --transform commonjs
40
lebab --replace ./ --transform exponent
41
lebab --replace ./ --transform multi-var
42
lebab --replace ./ --transform template
43
lebab --replace ./ --transform default-param
44
lebab --replace ./ --transform destruct-param
45
lebab --replace ./ --transform includes
Copied!

34. Troubleshoot Ubuntu Input/Output Error

Description: Open Powershell as Administrator...

Notes:
code:
1
wsl.exe --shutdown
2
3
Get-Service LxssManager | Restart-Service
Copied!

35. Export Medium as Markdown

Description:

Notes:
code:
1
npm i mediumexporter -g
2
3
4
mediumexporter https://medium.com/codex/fundamental-data-structures-in-javascript-8f9f709c15b4 >ds.md
Copied!

36. Delete files in violation of a given size range (100MB for git)

Description:

Notes:
code:
1
find . -size +75M -a -print -a -exec rm -f {} \;
2
3
4
5
6
find . -size +98M -a -print -a -exec rm -f {} \;
Copied!

37. download all links of given file type

Description:

Notes:
code:
1
wget -r -A.pdf https://overapi.com/git
Copied!

38. Kill all node processes

Description:

Notes:
code:
1
killall -s KILL node
Copied!

39. Remove string from file names recursively

Description: In the example below I am using this command to remove the string "-master" from all file names in the working directory and all of it's sub directories.

code:
1
find <mydir> -type f -exec sed -i 's/<string1>/<string2>/g' {} +
2
3
4
5
6
find . -type f -exec rename 's/-master//g' {} +
Copied!
Notes: The same could be done for folder names by changing the -type f flag (for file) to a -type d flag (for directory)
1
find <mydir> -type d -exec sed -i 's/<string1>/<string2>/g' {} +
2
3
4
5
6
find . -type d -exec rename 's/-master//g' {} +
Copied!

40. Remove spaces from file and folder names recursively

Description: replaces spaces in file and folder names with an _ underscore

Notes: need to run sudo apt install rename to use this command
code:
1
find . -name "* *" -type d | rename 's/ /_/g'
2
find . -name "* *" -type f | rename 's/ /_/g'
Copied!

41. Zip Each subdirectories in a given directory into their own zip file

Description:

Notes:
code:
1
for i in */; do zip -r "${i%/}.zip" "$i"; done
Copied!

42.

Description:

Notes:
code:
1
Copied!

43.

Description:

Notes:
code:
1
Copied!

44.

Description:

Notes:
code:
1
Copied!

45.

Description:

Notes:
code:
1
Copied!

46.

Description:

Notes:
code:
1
Copied!

47.

Description:

Notes:
code:
1
Copied!

48.

Description:

Notes:
code:
1
Copied!

49.

Description:

Notes:
code:
1
Copied!

50.

Description:

Notes:
code:
1
Copied!

51.

Description:

Notes:
code:
1
Copied!

52.

Description:

Notes:
code:
1
Copied!

53.

Description:

Notes:
code:
1
Copied!

54.

Description:

Notes:
code:
1
Copied!

55.

Description:

Notes:
code:
1
Copied!

56.

Description:

Notes:
code:
1
Copied!

57.

Description:

Notes:
code:
1
Copied!

58.

Description:

Notes:
code:
1
Copied!

59.

Description:

Notes:
code:
1
Copied!

60.

Description:

Notes:
code:
1
Copied!

61.

Description:

Notes:
code:
1
Copied!

62.

Description:

Notes:
code:
1
Copied!

63.

Description:

Notes:
code:
1
Copied!

64.

Description:

Notes:
code:
1
Copied!

65.

Description:

Notes:
code:
1
Copied!

66.

Description:

Notes:
code:
1
Copied!

67.

Description:

Notes:
code:
1
Copied!

68.

Description:

Notes:
code:
1
Copied!

69.

Description:

Notes:
code:
1
Copied!

70.

Description:

Notes:
code:
1
Copied!

71.

Description:

Notes:
code:
1
Copied!

72.

Description:

Notes:
code:
1
Copied!

73.

Description:

Notes:
code:
1
Copied!

74.

Description:

Notes:
code:
1
Copied!

75.

Description:

Notes:
code:
1
Copied!

76.

Description:

Notes:
code:
1
Copied!

77.

Description:

Notes:
code:
1
Copied!

78.

Description:

Notes:
code:
1
Copied!

79.

Description:

Notes:
code:
1
Copied!

80.

Description:

Notes:
code:
1
Copied!

81.

Description:

Notes:
code:
1
Copied!

82.

Description:

Notes:
code:
1
Copied!

83.

Description:

Notes:
code:
1
Copied!

84.

Description:

Notes:
code:
1
Copied!

85.

Description:

Notes:
code:
1
Copied!

86.

Description:

Notes:
code:
1
Copied!

87.

Description:

Notes:
code:
1
Copied!

88.

Description:

Notes:
code:
1
Copied!

89.

Description:

Notes:
code:
1
Copied!

90.

Description:

Notes:
code:
1
Copied!

91. Unzip PowerShell

Description:

Notes:
code:
1
PARAM (
2
[string] $ZipFilesPath = "./",
3
[string] $UnzipPath = "./RESULT"
4
)
5
6
$Shell = New-Object -com Shell.Application
7
$Location = $Shell.NameSpace($UnzipPath)
8
9
$ZipFiles = Get-Childitem $ZipFilesPath -Recurse -Include *.ZIP
10
11
$progress = 1
12
foreach ($ZipFile in $ZipFiles) {
13
Write-Progress -Activity "Unzipping to $($UnzipPath)" -PercentComplete (($progress / ($ZipFiles.Count + 1)) * 100) -CurrentOperation $ZipFile.FullName -Status "File $($Progress) of $($ZipFiles.Count)"
14
$ZipFolder = $Shell.NameSpace($ZipFile.fullname)
15
16
17
$Location.Copyhere($ZipFolder.items(), 1040) # 1040 - No msgboxes to the user - http://msdn.microsoft.com/en-us/library/bb787866%28VS.85%29.aspx
18
$progress++
19
}
Copied!

92. return to bash from zsh

Description:

Notes:
code:
1
sudo apt --purge remove zsh
Copied!

93. Symbolic Link

Description: to working directory

Notes:
code:
1
ln -s "$(pwd)" ~/NameOfLink
2
3
ln -s "$(pwd)" ~/Downloads
Copied!

94. auto generate readme

Description: rename existing readme to blueprint.md

Notes:
code:
1
npx @appnest/readme generate
Copied!

95. Log into postgres:

Description:

Notes:
code:
1
sudo -u postgres psql
Copied!

96. URL To Subscribe To YouTube Channel

Description:

Notes:
code:
1
https://www.youtube.com/channel/UC1HDa0wWnIKUf-b4yY9JecQ?sub_confirmation=1
Copied!

97. Embed Repl.it In Medium Post:

code:
1
https://repl.it/@bgoonz/Data-Structures-Algos-Codebase?lite=true&amp;referrer=https%3A%2F%2Fbryanguner.medium.com
2
3
4
https://repl.it/@bgoonz/node-db1-project?lite=true&amp;referrer=https%3A%2F%2Fbryanguner.medium.com
5
6
https://repl.it/@bgoonz/interview-prac?lite=true&amp;referrer=https%3A%2F%2Fbryanguner.medium.com
7
8
9
https://repl.it/@bgoonz/Database-Prac?lite=true&amp;referrer=https%3A%2F%2Fbryanguner.medium.com
Copied!

98.

Description:

Notes:
code:
1
find . -name *right.html -type f -exec sed -i 's/target="_parent"//g' {} +
2
3
4
find . -name *right.html -type f -exec sed -i 's/target="_parent"//g' {} +
Copied!

99. Cheat Sheet

Description:

Notes:
code:
1
#!/bin/bash
2
##############################################################################
3
# SHORTCUTS and HISTORY
4
##############################################################################
5
6
CTRL+A # move to beginning of line
7
CTRL+B # moves backward one character
8
CTRL+C # halts the current command
9
CTRL+D # deletes one character backward or logs out of current session, similar to exit
10
CTRL+E # moves to end of line
11
CTRL+F # moves forward one character
12
CTRL+G # aborts the current editing command and ring the terminal bell
13
CTRL+H # deletes one character under cursor (same as DELETE)
14
CTRL+J # same as RETURN
15
CTRL+K # deletes (kill) forward to end of line
16
CTRL+L # clears screen and redisplay the line
17
CTRL+M # same as RETURN
18
CTRL+N # next line in command history
19
CTRL+O # same as RETURN, then displays next line in history file
20
CTRL+P # previous line in command history
21
CTRL+Q # resumes suspended shell output
22
CTRL+R # searches backward
23
CTRL+S # searches forward or suspends shell output
24
CTRL+T # transposes two characters
25
CTRL+U # kills backward from point to the beginning of line
26
CTRL+V # makes the next character typed verbatim
27
CTRL+W # kills the word behind the cursor
28
CTRL+X # lists the possible filename completions of the current word
29
CTRL+Y # retrieves (yank) last item killed
30
CTRL+Z # stops the current command, resume with fg in the foreground or bg in the background
31
32
ALT+B # moves backward one word
33
ALT+D # deletes next word
34
ALT+F # moves forward one word
35
ALT+H # deletes one character backward
36
ALT+T # transposes two words
37
ALT+. # pastes last word from the last command. Pressing it repeatedly traverses through command history.
38
ALT+U # capitalizes every character from the current cursor position to the end of the word
39
ALT+L # uncapitalizes every character from the current cursor position to the end of the word
40
ALT+C # capitalizes the letter under the cursor. The cursor then moves to the end of the word.
41
ALT+R # reverts any changes to a command you’ve pulled from your history if you’ve edited it.
42
ALT+? # list possible completions to what is typed
43
ALT+^ # expand line to most recent match from history
44
45
CTRL+X then ( # start recording a keyboard macro
46
CTRL+X then ) # finish recording keyboard macro
47
CTRL+X then E # recall last recorded keyboard macro
48
CTRL+X then CTRL+E # invoke text editor (specified by $EDITOR) on current command line then execute resultes as shell commands
49
50
BACKSPACE # deletes one character backward
51
DELETE # deletes one character under cursor
52
53
history # shows command line history
54
!! # repeats the last command
55
!<n> # refers to command line 'n'
56
!<string> # refers to command starting with 'string'
57
58
exit # logs out of current session
59
60
61
##############################################################################
62
# BASH BASICS
63
##############################################################################
64
65
env # displays all environment variables
66
67
echo $SHELL # displays the shell you're using
68
echo $BASH_VERSION # displays bash version
69
70
bash # if you want to use bash (type exit to go back to your previously opened shell)
71
whereis bash # locates the binary, source and manual-page for a command
72
which bash # finds out which program is executed as 'bash' (default: /bin/bash, can change across environments)
73
74
clear # clears content on window (hide displayed lines)
75
76
77
##############################################################################
78
# FILE COMMANDS
79
##############################################################################
80
81
82
ls # lists your files in current directory, ls <dir> to print files in a specific directory
83
ls -l # lists your files in 'long format', which contains the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified
84
ls -a # lists all files in 'long format', including hidden files (name beginning with '.')
85
ln -s <filename> <link> # creates symbolic link to file
86
readlink <filename> # shows where a symbolic links points to
87
tree # show directories and subdirectories in easilly readable file tree
88
mc # terminal file explorer (alternative to ncdu)
89
touch <filename> # creates or updates (edit) your file
90
mktemp -t <filename> # make a temp file in /tmp/ which is deleted at next boot (-d to make directory)
91
cat <filename> # prints file raw content (will not be interpreted)
92
any_command > <filename> # '>' is used to perform redirections, it will set any_command's stdout to file instead of "real stdout" (generally /dev/stdout)
93
more <filename> # shows the first part of a file (move with space and type q to quit)
94
head <filename> # outputs the first lines of file (default: 10 lines)
95
tail <filename> # outputs the last lines of file (useful with -f option) (default: 10 lines)
96
vim <filename> # opens a file in VIM (VI iMproved) text editor, will create it if it doesn't exist
97
mv <filename1> <dest> # moves a file to destination, behavior will change based on 'dest' type (dir: file is placed into dir; file: file will replace dest (tip: useful for renaming))
98
cp <filename1> <dest> # copies a file
99
rm <filename> # removes a file
100
find . -name <name> <type> # searches for a file or a directory in the current directory and all its sub-directories by its name
101
diff <filename1> <filename2> # compares files, and shows where they differ
102
wc <filename> # tells you how many lines, words and characters there are in a file. Use -lwc (lines, word, character) to ouput only 1 of those informations
103
sort <filename> # sorts the contents of a text file line by line in alphabetical order, use -n for numeric sort and -r for reversing order.
104
sort -t -k <filename> # sorts the contents on specific sort key field starting from 1, using the field separator t.
105
rev # reverse string characters (hello becomes olleh)
106
chmod -options <filename> # lets you change the read, write, and execute permissions on your files (more infos: SUID, GUID)
107
gzip <filename> # compresses files using gzip algorithm
108
gunzip <filename> # uncompresses files compressed by gzip
109
gzcat <filename> # lets you look at gzipped file without actually having to gunzip it
110
lpr <filename> # prints the file
111
lpq # checks out the printer queue
112
lprm <jobnumber> # removes something from the printer queue
113
genscript # converts plain text files into postscript for printing and gives you some options for formatting
114
dvips <filename> # prints .dvi files (i.e. files produced by LaTeX)
115
grep <pattern> <filenames> # looks for the string in the files
116
grep -r <pattern> <dir> # search recursively for pattern in directory
117
head -n file_name | tail +n # Print nth line from file.
118
head -y lines.txt | tail +x # want to display all the lines from x to y. This includes the xth and yth lines.
119
120
121
##############################################################################
122
# DIRECTORY COMMANDS
123
##############################################################################
124
125
126
mkdir <dirname> # makes a new directory
127
rmdir <dirname> # remove an empty directory
128
rmdir -rf <dirname> # remove a non-empty directory
129
mv <dir1> <dir2> # rename a directory from <dir1> to <dir2>
130
cd # changes to home
131
cd .. # changes to the parent directory
132
cd <dirname> # changes directory
133
cp -r <dir1> <dir2> # copy <dir1> into <dir2> including sub-directories
134
pwd # tells you where you currently are
135
cd ~ # changes to home.
136
cd - # changes to previous working directory
137
138
##############################################################################
139
# SSH, SYSTEM INFO & NETWORK COMMANDS
140
##############################################################################
141
142
143
ssh [email protected] # connects to host as user
144
ssh -p <port> [email protected] # connects to host on specified port as user
145
ssh-copy-id [email protected] # adds your ssh key to host for user to enable a keyed or passwordless login
146
147
whoami # returns your username
148
passwd # lets you change your password
149
quota -v # shows what your disk quota is
150
date # shows the current date and time
151
cal # shows the month's calendar
152
uptime # shows current uptime
153
w # displays whois online
154
finger <user> # displays information about user
155
uname -a # shows kernel information
156
man <command> # shows the manual for specified command
157
df # shows disk usage
158
du <filename> # shows the disk usage of the files and directories in filename (du -s give only a total)
159
last <yourUsername> # lists your last logins
160
ps -u yourusername # lists your processes
161
kill <PID> # kills the processes with the ID you gave
162
killall <processname> # kill all processes with the name
163
top # displays your currently active processes
164
lsof # lists open files
165
bg # lists stopped or background jobs ; resume a stopped job in the background
166
fg # brings the most recent job in the foreground
167
fg <job> # brings job to the foreground
168
169
ping <host> # pings host and outputs results
170
whois <domain> # gets whois information for domain
171
dig <domain> # gets DNS information for domain
172
dig -x <host> # reverses lookup host
173
wget <file> # downloads file
174
175
time <command> # report time consumed by command execution
176
177
178
##############################################################################
179
# VARIABLES
180
##############################################################################
181
182
183
varname=value # defines a variable
184
varname=value command # defines a variable to be in the environment of a particular subprocess
185
echo $varname # checks a variable's value
186
echo $ # prints process ID of the current shell
187
echo $! # prints process ID of the most recently invoked background job
188
echo $? # displays the exit status of the last command
189
read <varname> # reads a string from the input and assigns it to a variable
190
read -p "prompt" <varname> # same as above but outputs a prompt to ask user for value
191
column -t <filename> # display info in pretty columns (often used with pipe)
192
let <varname> = <equation> # performs mathematical calculation using operators like +, -, *, /, %
193
export VARNAME=value # defines an environment variable (will be available in subprocesses)
194
195
array[0]=valA # how to define an array
196
array[1]=valB
197
array[2]=valC
198
array=([2]=valC [0]=valA [1]=valB) # another way
199
array=(valA valB valC) # and another
200
201
${array[i]} # displays array's value for this index. If no index is supplied, array element 0 is assumed
202
${#array[i]} # to find out the length of any element in the array
203
${#array[@]} # to find out how many values there are in the array
204
205
declare -a # the variables are treated as arrays
206
declare -f # uses function names only
207
declare -F # displays function names without definitions
208
declare -i # the variables are treated as integers
209
declare -r # makes the variables read-only
210
declare -x # marks the variables for export via the environment
211
212
${varname:-word} # if varname exists and isn't null, return its value; otherwise return word
213
${varname:word} # if varname exists and isn't null, return its value; otherwise return word
214
${varname:=word} # if varname exists and isn't null, return its value; otherwise set it word and then return its value
215
${varname:?message} # if varname exists and isn't null, return its value; otherwise print varname, followed by message and abort the current command or script
216
${varname:+word} # if varname exists and isn't null, return word; otherwise return null
217
${varname:offset:length} # performs substring expansion. It returns the substring of $varname starting at offset and up to length characters
218
219
${variable#pattern} # if the pattern matches the beginning of the variable's value, delete the shortest part that matches and return the rest
220
${variable##pattern} # if the pattern matches the beginning of the variable's value, delete the longest part that matches and return the rest
221
${variable%pattern} # if the pattern matches the end of the variable's value, delete the shortest part that matches and return the rest
222
${variable%%pattern} # if the pattern matches the end of the variable's value, delete the longest part that matches and return the rest
223
${variable/pattern/string} # the longest match to pattern in variable is replaced by string. Only the first match is replaced
224
${variable//pattern/string} # the longest match to pattern in variable is replaced by string. All matches are replaced
225
226
${#varname} # returns the length of the value of the variable as a character string
227
228
*(patternlist) # matches zero or more occurrences of the given patterns
229
+(patternlist) # matches one or more occurrences of the given patterns
230
?(patternlist) # matches zero or one occurrence of the given patterns
231
@(patternlist) # matches exactly one of the given patterns
232
!(patternlist) # matches anything except one of the given patterns
233
234
$(UNIX command) # command substitution: runs the command and returns standard output
235
236
237
##############################################################################
238
# FUNCTIONS
239
##############################################################################
240
241
242
# The function refers to passed arguments by position (as if they were positional parameters), that is, $1, $2, and so forth.
243
# [email protected] is equal to "$1" "$2"... "$N", where N is the number of positional parameters. $# holds the number of positional parameters.
244
245
246
function functname() {
247
shell commands
248
}
249
250
unset -f functname # deletes a function definition
251
declare -f # displays all defined functions in your login session
252
253
254
##############################################################################
255
# FLOW CONTROLS
256
##############################################################################
257
258
259
statement1 && statement2 # and operator
260
statement1 || statement2 # or operator
261
262
-a # and operator inside a test conditional expression
263
-o # or operator inside a test conditional expression
264
265
# STRINGS
266
267
str1 == str2 # str1 matches str2
268
str1 != str2 # str1 does not match str2
269
str1 < str2 # str1 is less than str2 (alphabetically)
270
str1 > str2 # str1 is greater than str2 (alphabetically)
271
str1 \> str2 # str1 is sorted after str2
272
str1 \< str2 # str1 is sorted before str2
273
-n str1 # str1 is not null (has length greater than 0)
274
-z str1 # str1 is null (has length 0)
275
276
# FILES
277
278
-a file # file exists or its compilation is successful
279
-d file # file exists and is a directory
280
-e file # file exists; same -a
281
-f file # file exists and is a regular file (i.e., not a directory or other special type of file)
282
-r file # you have read permission
283
-s file # file exists and is not empty
284
-w file # your have write permission
285
-x file # you have execute permission on file, or directory search permission if it is a directory
286
-N file # file was modified since it was last read
287
-O file # you own file
288
-G file # file's group ID matches yours (or one of yours, if you are in multiple groups)
289
file1 -nt file2 # file1 is newer than file2
290
file1 -ot file2 # file1 is older than file2
291
292
# NUMBERS
293
294
-lt # less than
295
-le # less than or equal
296
-eq # equal
297
-ge # greater than or equal
298
-gt # greater than
299
-ne # not equal
300
301
if condition
302
then
303
statements
304
[elif condition
305
then statements...]
306
[else
307
statements]
308
fi
309
310
for x in {1..10}
311
do
312
statements
313
done
314
315
for name [in list]
316
do
317
statements that can use $name
318
done
319
320
for (( initialisation ; ending condition ; update ))
321
do
322
statements...
323
done
324
325
case expression in
326
pattern1 )
327
statements ;;
328
pattern2 )
329
statements ;;
330
esac
331
332
select name [in list]
333
do
334
statements that can use $name
335
done
336
337
while condition; do
338
statements
339
done
340
341
until condition; do
342
statements
343
done
344
345
##############################################################################
346
# COMMAND-LINE PROCESSING CYCLE
347
##############################################################################
348
349
350
# The default order for command lookup is functions, followed by built-ins, with scripts and executables last.
351
# There are three built-ins that you can use to override this order: `command`, `builtin` and `enable`.
352
353
command # removes alias and function lookup. Only built-ins and commands found in the search path are executed
354
builtin # looks up only built-in commands, ignoring functions and commands found in PATH
355
enable # enables and disables shell built-ins
356
357
eval # takes arguments and run them through the command-line processing steps all over again
358
359
360
##############################################################################
361
# INPUT/OUTPUT REDIRECTORS
362
##############################################################################
363
364
365
cmd1|cmd2 # pipe; takes standard output of cmd1 as standard input to cmd2
366
< file # takes standard input from file
367
> file # directs standard output to file
368
>> file # directs standard output to file; append to file if it already exists
369
>|file # forces standard output to file even if noclobber is set
370
n>|file # forces output to file from file descriptor n even if noclobber is set
371
<> file # uses file as both standard input and standard output
372
n<>file # uses file as both input and output for file descriptor n
373
n>file # directs file descriptor n to file
374
n<file # takes file descriptor n from file
375
n>>file # directs file description n to file; append to file if it already exists
376
n>& # duplicates standard output to file descriptor n
377
n<& # duplicates standard input from file descriptor n
378
n>&m # file descriptor n is made to be a copy of the output file descriptor
379
n<&m # file descriptor n is made to be a copy of the input file descriptor
380
&>file # directs standard output and standard error to file
381
<&- # closes the standard input
382
>&- # closes the standard output
383
n>&- # closes the ouput from file descriptor n
384
n<&- # closes the input from file descripor n
385
386
|tee <file># output command to both terminal and a file (-a to append to file)
387
388
389
##############################################################################
390
# PROCESS HANDLING
391
##############################################################################
392
393
394
# To suspend a job, type CTRL+Z while it is running. You can also suspend a job with CTRL+Y.
395
# This is slightly different from CTRL+Z in that the process is only stopped when it attempts to read input from terminal.
396
# Of course, to interrupt a job, type CTRL+C.
397
398
myCommand & # runs job in the background and prompts back the shell
399
400
jobs # lists all jobs (use with -l to see associated PID)
401
402
fg # brings a background job into the foreground
403
fg %+ # brings most recently invoked background job
404
fg %- # brings second most recently invoked background job
405
fg %N # brings job number N
406
fg %string # brings job whose command begins with string
407
fg %?string # brings job whose command contains string
408
409
kill -l # returns a list of all signals on the system, by name and number
410
kill PID # terminates process with specified PID
411
kill -s SIGKILL 4500 # sends a signal to force or terminate the process
412
kill -15 913 # Ending PID 913 process with signal 15 (TERM)
413
kill %1 # Where %1 is the number of job as read from 'jobs' command.
414
415
ps # prints a line of information about the current running login shell and any processes running under it
416
ps -a # selects all processes with a tty except session leaders
417
418
trap cmd sig1 sig2 # executes a command when a signal is received by the script
419
trap "" sig1 sig2 # ignores that signals
420
trap - sig1 sig2 # resets the action taken when the signal is received to the default
421
422
disown <PID|JID> # removes the process from the list of jobs
423
424
wait # waits until all background jobs have finished
425
sleep <number> # wait # of seconds before continuing
426
427
pv # display progress bar for data handling commands. often used with pipe like |pv
428
yes # give yes response everytime an input is requested from script/process
429
430
431
##############################################################################
432
# TIPS & TRICKS
433
##############################################################################
434
435
436
# set an alias
437
cd; nano .bash_profile
438
> alias gentlenode='ssh [email protected] -p 3404' # add your alias in .bash_profile
439
440
# to quickly go to a specific directory
441
cd; nano .bashrc
442
> shopt -s cdable_vars
443
> export websites="/Users/mac/Documents/websites"
444
445
source .bashrc
446
cd $websites
447
448
449
##############################################################################
450
# DEBUGGING SHELL PROGRAMS
451
##############################################################################
452
453
454
bash -n scriptname # don't run commands; check for syntax errors only
455
set -o noexec # alternative (set option in script)
456
457
bash -v scriptname # echo commands before running them
458
set -o verbose # alternative (set option in script)
459
460
bash -x scriptname # echo commands after command-line processing
461
set -o xtrace # alternative (set option in script)
462
463
trap 'echo $varname' EXIT # useful when you want to print out the values of variables at the point that your script exits
464
465
function errtrap {
466
es=$?
467
echo "ERROR line $1: Command exited with status $es."
468
}
469
470
trap 'errtrap $LINENO' ERR # is run whenever a command in the surrounding script or function exits with non-zero status
471
472
function dbgtrap {
473
echo "badvar is $badvar"
474
}
475
476
trap dbgtrap DEBUG # causes the trap code to be executed before every statement in a function or script
477
# ...section of code in which the problem occurs...
478
trap - DEBUG # turn off the DEBUG trap
479
480
function returntrap {
481
echo "A return occurred"
482
}
483
484
trap returntrap RETURN # is executed each time a shell function or a script executed with the . or source commands finishes executing
485
486
##############################################################################
487
# COLORS AND BACKGROUNDS
488
##############################################################################
489
# note: \e or \x1B also work instead of \033
490
# Reset
491
Color_Off='\033[0m' # Text Reset
492
493
# Regular Colors
494
Black='\033[0;30m' # Black
495
Red='\033[0;31m' # Red
496
Green='\033[0;32m' # Green
497
Yellow='\033[0;33m' # Yellow
498
Blue='\033[0;34m' # Blue
499
Purple='\033[0;35m' # Purple
500
Cyan='\033[0;36m' # Cyan
501
White='\033[0;97m' # White
502
503
# Additional colors
504
LGrey='\033[0;37m' # Ligth Gray
505
DGrey='\033[0;90m' # Dark Gray
506
LRed='\033[0;91m' # Ligth Red
507
LGreen='\033[0;92m' # Ligth Green
508
LYellow='\033[0;93m'# Ligth Yellow
509
LBlue='\033[0;94m' # Ligth Blue
510
LPurple='\033[0;95m'# Light Purple
511
LCyan='\033[0;96m' # Ligth Cyan
512
513
514
# Bold
515
BBlack='\033[1;30m' # Black
516
BRed='\033[1;31m' # Red
517
BGreen='\033[1;32m' # Green
518
BYellow='\033[1;33m'# Yellow
519
BBlue='\033[1;34m' # Blue
520
BPurple='\033[1;35m'# Purple
521
BCyan='\033[1;36m' # Cyan
522
BWhite='\033[1;37m' # White
523
524
# Underline
525
UBlack='\033[4;30m' # Black
526
URed='\033[4;31m' # Red
527
UGreen='\033[4;32m' # Green
528
UYellow='\033[4;33m'# Yellow
529
UBlue='\033[4;34m' # Blue
530
UPurple='\033[4;35m'# Purple
531
UCyan='\033[4;36m' # Cyan
532
UWhite='\033[4;37m' # White
533
534
# Background
535
On_Black='\033[40m' # Black
536
On_Red='\033[41m' # Red
537
On_Green='\033[42m' # Green
538
On_Yellow='\033[43m'# Yellow
539
On_Blue='\033[44m' # Blue
540
On_Purple='\033[45m'# Purple
541
On_Cyan='\033[46m' # Cyan
542
On_White='\033[47m' # White
543
544
# Example of usage
545
echo -e "${Green}This is GREEN text${Color_Off} and normal text"
546
echo -e "${Red}${On_White}This is Red test on White background${Color_Off}"
547
# option -e is mandatory, it enable interpretation of backslash escapes
548
printf "${Red} This is red \n"
Copied!
Last modified 24d ago
Copy link
Contents
Resources:
1. Remove spaces from file and folder names and then remove numbers from files and folder names....
2. Download Website Using Wget:
3. Clean Out Messy Git Repo:
4. clone all of a user's git repositories
Generalized:
Clone all Git User
Clone all Git Organization:
5. Git Workflow
6. Recursive Unzip In Place
7. git pull keeping local changes:
8. Prettier Code Formatter:
9. Pandoc
10. Gitpod Installs
11. Repo Utils Package:
12. Unix Tree Package Usage:
13. Find & Replace string in file & folder names recursively..
14. Remove double extensions :
15. Truncate folder names down to 12 characters:
16.Appendir.js
17. Replace space in filename with underscore
18. Filter & delete files by name and extension
19. Remove lines containing string:
20. Remove duplicate lines from a text file
21. Remove lines containing string:
22. Zip directory excluding .git and node_modules all the way down (Linux)
23. Delete files containing a certain string:
24.
25. Index of Iframes
26. Filter Corrupted Git Repo For Troublesome File:
27. OVERWRITE LOCAL CHANGES:
28. Remove Submodules:
29. GET GISTS
30. Remove Remote OriginL
31. just clone .git folder:
32. Undo recent pull request:
33. Lebab
34. Troubleshoot Ubuntu Input/Output Error
35. Export Medium as Markdown
36. Delete files in violation of a given size range (100MB for git)
37. download all links of given file type
38. Kill all node processes
39. Remove string from file names recursively
40. Remove spaces from file and folder names recursively
41. Zip Each subdirectories in a given directory into their own zip file
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91. Unzip PowerShell
92. return to bash from zsh
93. Symbolic Link
94. auto generate readme
95. Log into postgres:
96. URL To Subscribe To YouTube Channel
97. Embed Repl.it In Medium Post:
98.
99. Cheat Sheet